Loadingscreen = function(ctx,preloader){

	this.ctx = ctx;
	this.preloader = preloader;
	this.onHold = true;
	this.type='LoadingScreen';
	this.gameloop = null;

	this.init = function(gameloop){
		this.gameloop = gameloop;
	};

	this.loop = function(){

		var state = this.preloader.loadingStatus();
		
		if( state < 0.999 ) {
			this.draw(state);
			return null;
		} else {
			return 'next';
		}

	}

	this.draw = function(state){
		this.ctx.fillStyle = '#000000';
		this.ctx.fillRect(0,0,700,700);

		this.ctx.fillStyle = '#833b01';
		this.ctx.strokeStyle = '#ba5301';

		this.ctx.fillText('Loading...',150,205);
		this.ctx.strokeRect(150,220,400,20);
		this.ctx.fillRect(151,221,state*398,18);
	}

}